<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVisitRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('visit_records', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('order_id')->comment('订单ID');
            $table->unsignedInteger('flow_channel_id')->nullable()->comment('流量渠道ID');
            $table->string('ip')->index()->comment('ip');
            $table->string('u_id')->index()->comment('平台用户标识');
            $table->date('date')->index()->comment('日期');
            $table->integer('hour')->comment('小时');
            $table->integer('min_area')->comment('分钟区间');
            $table->integer('visit_num')->default(0)->comment('访问次数');
            $table->unsignedInteger('domain_id')->default(null)->comment('域名ID');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('visit_records');
    }
}
